<?php /* PROJECTS $Id: do_project_aed.php,v 1.11.10.4 2006/07/25 20:24:13 merlinyoda Exp $ */
require_once ($AppUI->getModuleClass('projects'));
require_once(DP_BASE_DIR."/modules/masterdata/mdstatus.class.php");
$projectsArr = dPgetParam( $_POST, 'checkProcess', array());
$obj = new CProject();
$processed_status = new CMDStatus();
$project_processed = dPgetSysVal( 'ProjectProcessed' );
$processed_status->loadByCode($project_processed[0]);
?>
<table cellspacing="0" cellpadding="3" border="0" width="100%" class="infopanel">
<tr>
	<td><?=$AppUI->_('Results of references processing')?></td>
</tr>
</table>
<table id="idReferenceList" class="list" cellspacing="0" cellpadding="2" border="0" width="100%">
<tr>
	<th><?=$AppUI->_('Reference')?></td>
	<th><?=$AppUI->_('Result')?></td>
</tr>
<?php
$i = 0;
foreach($projectsArr as $project_id) {
	$class= $i % 2 == 0 ? "second" : "first";
	$i++;
	echo "<tr class='$class'>";
	if ($obj->load($project_id) === false) {
		echo "<td> $project_id </td><td>".$AppUI->_('Failed to load project with id: ') . $project_id . "</td>";
		echo "</tr>";
		continue;
	}
	$reasons = $obj->canProcess();
	if($reasons != NULL) {
		echo "<td> {$obj->project_name}</td><td>".$AppUI->_('Failed to process: ') . $reasons . "</td>";
		echo "</tr>";
		continue;
	}
	$obj->project_rstatus = $processed_status->status_id;
	if (($msg = $obj->store())) {
		echo "<td> {$obj->project_name}</td><td>".$AppUI->_('Failed to process: ') . $msg . "</td>";
		echo "</tr>";
		continue;
	}
	echo "<td> {$obj->project_name}</td><td>". dPshowImage("images/green.png"). "</td>";
	echo "</tr>";
}
?>
<tr>
	<th colspan="100%"><input type="button" name="back" value="<?=$AppUI->_('Back')?>" onclick="go('?<?=$AppUI->getPlace()?>')"/></th>
</tr>
</table>